package com.xdq.spring.service;

import com.xdq.spring.model.Transmission;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

@Service
//默认作用域
@Scope("singleton")
public class TransmissionProducer {

    private List<Transmission> transmissions =new ArrayList<>();

    public TransmissionProducer(){
        System.out.println("TransmissionProducer被实例化了");
    }

    public List<Transmission> produces(String type,int count){
        for(int i=0;i<count;i++){
            Transmission engine=new Transmission();
            engine.setBrand("ABB");
            engine.setType(type);
            engine.setCreateDate(String.valueOf(System.currentTimeMillis()));
            engine.setSerialNo(UUID.randomUUID().toString());
            transmissions.add(engine);
        }
        return transmissions;
    }
}
